<template>
  <div id="orderDetailDiv">
    <div style="margin:0;border-bottom:1px solid #DCDFE6;overflow:hidden">
      <div style="color:#2B7DBC;font-size:16px;float:left;">订单详情</div>
      <el-form>
        <el-form-item style="margin:0;">
          <el-button
            @click="goback()"
            size="mini"
            type="primary"
            style="float:right;margin-bottom:5px"
            >返回</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div id="orderBaseInfo">
      <el-form
        :inline="true"
        :model="orderItem"
        class="demo-form-inline"
        id="orderDetailForm"
      >
        <el-form-item label="　　订单编号：">
          <el-input v-model="orderItem.orderNo" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　订单状态：">
          <el-input
            v-model="orderItem.orderStatusName"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <el-form-item label="　　下单时间：">
          <el-input v-model="orderItem.orderTime" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　订单来源：">
          <el-input
            v-model="orderItem.orderSourceName"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <br />
        <el-form-item label="　　店铺名称：">
          <el-input v-model="orderItem.storeName" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　店铺授权码：">
          <el-input v-model="orderItem.authCode" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　店主姓名：">
          <el-input
            v-model="orderItem.shopOwnerName"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <el-form-item label="　店主手机号：">
          <el-input
            v-model="orderItem.shopOwnerPhone"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <br />
        <el-form-item label="　　大区名称：">
          <el-input v-model="orderItem.warzoneName" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　营销区域名称：">
          <el-input v-model="orderItem.baseName" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　店铺地址：">
          <el-input
            v-model="orderItem.storeAddress"
            :readonly="true"
            style="width:470px"
          ></el-input>
        </el-form-item>
        <br />
        <el-form-item label="　　会员姓名：">
          <el-input v-model="orderItem.memberName" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　会员手机号：">
          <el-input v-model="orderItem.memberPhone" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　会员等级：">
          <el-input
            v-model="orderItem.gradelevelName"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <br />
        <el-form-item label="　收货人姓名：">
          <el-input v-model="orderItem.postPerson" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　收货人电话：">
          <el-input
            v-model="orderItem.postPersonTel"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <el-form-item label="　　收货地址：">
          <el-input
            v-model="orderItem.postAddress"
            :readonly="true"
            style="width:470px"
          ></el-input>
        </el-form-item>
        <br />
        <el-form-item label="是否包含限购品：">
          <el-input
            v-model="orderItem.haveBuyLimitName"
            :readonly="true"
            style="width:168px"
          ></el-input>
        </el-form-item>
        <el-form-item label="是否包含赠品：" style="margin-left:-10px">
          <el-input
            v-model="orderItem.haveGiftOrderName"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <el-form-item label="是否包含宴席信息：">
          <el-input
            v-model="orderItem.isFeastOrder"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <br />
        <el-form-item label="　　付款时间：">
          <el-input v-model="orderItem.payTime" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　配送方式：">
          <el-input
            v-model="orderItem.deliveryMethodName"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <el-form-item label="　　发货时间：">
          <el-input
            v-model="orderItem.deliveryTime"
            :readonly="true"
          ></el-input>
        </el-form-item>
        <br />
        <el-form-item label="　　退款时间：">
          <el-input v-model="orderItem.refundDate" :readonly="true"></el-input>
        </el-form-item>
        <el-form-item label="　　订单完成时间：">
          <el-input
            v-model="orderItem.completeDate"
            :readonly="true"
          ></el-input>
        </el-form-item>
      </el-form>
    </div>
    <!--支付列表-->
    <el-divider content-position="left">订单支付信息</el-divider>
    <div class="table2">
      <el-table
        ref="table2"
        key="table2"
        tooltip-effect="dark"
        style="width: 100%"
        v-loading="loading2"
        :data="payData"
        border
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      >
        <el-table-column
          prop="payMethod"
          label="支付类型"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.payMethod == 0">云店线下</span>
            <span v-if="scope.row.payMethod == 1">线上支付</span>
            <span v-if="scope.row.payMethod == 2">pos线下支付</span>
            <span v-if="scope.row.payMethod == 3">微信</span>
            <span v-if="scope.row.payMethod == 4">支付宝</span>
            <span v-if="scope.row.payMethod == 5">银行卡</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="totalMoney"
          label="订单原价"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          prop="couponType"
          label="通用券类型"
          align="center"
          width="120"
          :formatter="couponType"
        ></el-table-column>
        <el-table-column
          prop="couponName"
          label="券属性"
          align="center"
          show-overflow-tooltip
          :formatter="couponDetail"
        ></el-table-column>
        <el-table-column
          prop="couponDeductMoney"
          label="通用券抵扣金额"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          prop="discountMoney"
          label="定向券抵扣金额"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          prop="payMoney"
          label="订单实付金额"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          prop="payTime"
          label="支付时间"
          align="center"
          width="200"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column prop="payStatus" label="支付状态" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.payStatus == 0 && orderItem.returnStatus == 0"
              >待支付</span
            >
            <span v-if="scope.row.payStatus == 1 && orderItem.returnStatus == 0"
              >已支付</span
            >
            <span v-if="orderItem.returnStatus != 0">已退款</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!--商品列表-->
    <el-divider content-position="left">订单商品信息</el-divider>
    <div class="table3">
      <el-table
        ref="table3"
        key="table3"
        tooltip-effect="dark"
        style="width: 100%"
        v-loading="loading3"
        :data="itemData"
        border
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      >
        <el-table-column
          prop="goodsSeq"
          label="商品编号"
          align="center"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="goodsName"
          label="商品名称"
          align="center"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="goodsStyle"
          label="商品类型"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <span v-if="scope.row.goodsStyle == 1">普通商品</span>
            <span v-if="scope.row.goodsStyle == 2">宴席商品</span>
            <span v-if="scope.row.goodsStyle == 3">生日专属商品</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="goodsPic"
          label="商品图片"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            <img
              :src="scope.row.goodsPic"
              v-if="scope.row.goodsPic != '' && scope.row.goodsPic != null"
              width="70"
              height="50"
            />
          </template>
        </el-table-column>
        <el-table-column
          prop="amount"
          label="购买数量"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            <span>{{ scope.row.amount }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="minAmount"
          label="折算瓶数"
          align="center"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="oldMoney"
          label="商品原价"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          prop="memberMoney"
          label="商品会员价"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          prop="couponNum"
          label="券数量"
          align="center"
          width="120"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.couponNum <= 0">—</span>
            <span v-if="scope.row.couponNum > 0">
              <el-button
                size="mini"
                @click="showCouponDetail(scope.row)"
                type="text"
                >{{ scope.row.couponNum }}</el-button
              >
            </span>
          </template>
        </el-table-column>
        <el-table-column type="expand" width="1">
          <template slot-scope="props">
            <div id="couponDetail" style="width:600px;">
              <div style="margin:0 10px 10px 0">卡券详情</div>
              <el-table
                ref="couponTable"
                tooltip-effect="dark"
                :data="props.row.coupouList"
                width="100%"
              >
                <el-table-column
                  prop="goodsName"
                  label="商品名称"
                  align="center"
                  width="150"
                  show-overflow-tooltip
                >
                  <template>
                    <span>{{ props.row.goodsName }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="couponType"
                  label="定向券类型"
                  align="center"
                  width="150"
                  :formatter="couponType"
                ></el-table-column>
                <el-table-column
                  prop="couponName"
                  label="券属性"
                  align="center"
                  width="150"
                  show-overflow-tooltip
                  :formatter="couponDetail"
                ></el-table-column>
                <el-table-column
                  prop="couponMoney"
                  label="抵扣金额"
                  align="center"
                  width="150"
                  :formatter="fixData"
                ></el-table-column>
              </el-table>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="discount"
          label="抵扣金额"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          v-if="orderItem.returnStatus == 0"
          prop="realMoney"
          label="商品实付金额"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
        <el-table-column
          v-if="orderItem.returnStatus != 0"
          prop="realMoney"
          label="退款金额"
          align="center"
          width="120"
          :formatter="fixData"
        ></el-table-column>
      </el-table>
    </div>
    <!--退款商品列表-->
    <el-divider content-position="left" v-if="orderItem.returnStatus != 0"
      >退款信息</el-divider
    >
    <div class="table4" v-if="orderItem.returnStatus != 0">
      <el-table
        ref="table4"
        key="table4"
        tooltip-effect="dark"
        style="width: 800px"
        v-loading="loading4"
        :data="returnData"
        border
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      >
        <el-table-column
          prop="orderNo"
          label="退款单编号"
          align="center"
          width="200"
        ></el-table-column>
        <el-table-column
          prop="goodsName"
          label="退款商品名称"
          align="center"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="orderTime"
          label="退款时间"
          align="center"
          width="200"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="realMoney"
          label="退款金额"
          align="center"
          width="150"
          :formatter="fixData"
        ></el-table-column>
      </el-table>
    </div>
    <!--宴席列表-->
    <el-divider content-position="left" v-if="orderItem.isFeastOrder == '是'"
      >宴席信息</el-divider
    >
    <div class="table7" v-if="orderItem.isFeastOrder == '是'">
      <el-table
        ref="table7"
        key="table7"
        tooltip-effect="dark"
        style="width: 100%"
        v-loading="loading7"
        :data="feastData"
        border
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      >
        <el-table-column
          prop="banquetType"
          label="宴席类型"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.banquetType == 'CELEBRATE_BANQUET'"
              >庆功宴</span
            >
            <span v-if="scope.row.banquetType == 'MARRY'">婚宴</span>
            <span v-if="scope.row.banquetType == 'BIRTHDAY'">寿宴</span>
            <span v-if="scope.row.banquetType == 'SCHOOL'">升学宴</span>
            <span v-if="scope.row.banquetType == 'OTHER'">其他</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="feastBeginTime"
          label="宴席时间"
          align="center"
          width="150"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            {{ scope.row.feastDate }} {{ scope.row.feastBeginTime }}
          </template>
        </el-table-column>
        <el-table-column
          prop="feastAddressDetail"
          label="宴席地址"
          align="center"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="hotelAddress"
          label="宴席酒店"
          align="center"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="tableNumber"
          label="宴席桌数"
          align="center"
          width="120"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="goodsName"
          label="宴席用酒"
          align="center"
          width="150"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="quantity"
          label="箱数"
          align="center"
          width="120"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="contacts"
          label="奖品联系人"
          align="center"
          width="150"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="contactsPhone"
          label="奖品联系方式"
          align="center"
          width="150"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="contactsAddressDetail"
          label="奖品收货地址"
          align="center"
          width="200"
          show-overflow-tooltip
        ></el-table-column>
      </el-table>
    </div>
    <!--赠品列表-->
    <el-divider content-position="left" v-if="orderItem.haveGiftOrder == 1"
      >赠品详情</el-divider
    >
    <div class="table6" v-if="orderItem.haveGiftOrder == 1">
      <el-table
        ref="table6"
        key="table6"
        tooltip-effect="dark"
        style="width: 800px"
        v-loading="loading6"
        :data="giftData"
        border
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      >
        <el-table-column
          prop="giftCode"
          label="赠品编号"
          align="center"
          width="200"
        ></el-table-column>
        <el-table-column
          prop="giftName"
          label="赠品名称"
          align="center"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="giftPic"
          label="商品图片"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <img
              :src="scope.row.giftPic"
              v-if="scope.row.giftPic != '' && scope.row.giftPic != null"
              width="70"
              height="50"
            />
          </template>
        </el-table-column>
        <el-table-column
          prop="giftCount"
          label="赠品数量（件）"
          align="center"
          width="150"
        ></el-table-column>
      </el-table>
    </div>

    <!-- 取货码显示 -->
    <template v-if="orderItem.orderStatus == 2">
      <el-divider content-position="left">取货码</el-divider>
      <div class="pick-up-code">
        {{ tdcode ? tdcode : '暂无取货码'  }}
      </div>
    </template>

    <!--物流列表-->
    <el-divider content-position="left" v-if="orderItem.returnStatus == 0"
      >物流信息</el-divider
    >
    <div class="table5" v-if="orderItem.returnStatus == 0">
      <el-table
        ref="table5"
        key="table5"
        tooltip-effect="dark"
        style="width: 800px"
        v-loading="loading5"
        :data="deliverData"
        border
        :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
      >
        <el-table-column
          prop="deliveryTypeName"
          label="配送方式"
          align="center"
        ></el-table-column>
        <el-table-column prop="userName" label="业务员名称" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.deliveryType != 2">—</span>
            <span v-if="scope.row.deliveryType == 2">{{
              scope.row.userName
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="companyName" label="快递名称" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.deliveryType != 3">—</span>
            <span v-if="scope.row.deliveryType == 3">{{
              scope.row.companyName
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="nu" label="快递单号" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.deliveryType != 3">—</span>
            <span v-if="scope.row.deliveryType == 3">
              <el-button
                size="mini"
                @click="showDeliverDetail(scope.row)"
                type="text"
                >{{ scope.row.nu }}</el-button
              >
            </span>
          </template>
        </el-table-column>
        <el-table-column type="expand" width="1">
          <template slot-scope="scope">
            <div id="deliverDetail">
              <div style="margin:0 10px 10px 0">物流详细</div>
              <div>
                <!--
                <el-timeline :reverse="deliverDetailReverse">
                  <el-timeline-item
                    v-for="(deliverDetailOne, index) in props.row.data"
                    :key="index"
                    :timestamp="deliverDetailOne.ftime">
                    {{deliverDetailOne.context}}
                  </el-timeline-item>
                </el-timeline>
                -->
                <iframe
                  :src="
                    'https://www.kuaidi100.com/chaxun?com=' +
                      scope.row.com +
                      '&nu=' +
                      scope.row.nu
                  "
                  style="width:100%;height:500px"
                  frameborder="0"
                  name="快递详细"
                  scrolling="auto"
                ></iframe>
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import {
  queryTradeOrderPayInfo,
  queryTradeOrderItemList,
  queryTradeOrderGiftList,
  queryTradeOrderFeastList,
  queryTradeOrderDeliverList,
  queryTdcode
} from '@/api/tradeOrderSearch';
import qs from 'qs';

export default {
  data() {
    return {
      loading: true,
      loading2: true,
      loading3: true,
      loading4: true,
      loading5: true,
      loading6: true,
      loading7: true,
      payData: [], //支付列表数据
      itemData: [], //商品列表数据
      returnData: [], //退款列表数据
      deliverData: [], //物流列表数据
      giftData: [], //赠品列表数据
      feastData: [], //宴席列表数据
      deliverDetailReverse: false, //物流数据不倒置
      orderItem: {
        uuid: '',
        orderNo: '',
        orgSeq: '',
        orderStatus: '',
        returnStatus: '',
        orderStatusName: '',
        customizeStatus: '',
        orderTime: '',
        payTime: '',
        deliveryMethodName: '',
        deliveryTime: '',
        storeName: '',
        shopOwnerName: '',
        shopOwnerPhone: '',
        warzoneName: '',
        baseName: '',
        gradelevelName: '',
        memberName: '',
        memberPhone: '',
        storeAddress: '',
        authCode: '',
        postPerson: '',
        postPersonTel: '',
        postAddress: '',
        haveBuyLimitName: '',
        haveGiftOrder: '',
        haveGiftOrderName: '',
        orderSourceName: '',
        isFeastOrder: '',
        feastInfo: '',
        completeDate: '',
        refundDate: '',
      }, //订单详情表头信息字段

      tdcode: '',  // 取货码
    };
  },
  mounted() {
    let v = this.$route.params.edit;
    this.showOrderDetail(v);
    if(v.orderStatus == 2){
      this.queryTdcode(v.uuid);
    }
  },
  filters: {
    numFilter(value) {
      let realVal = '';
      if (!isNaN(value) && value !== '') {
        // 截取当前数据到小数点后2位
        realVal = parseFloat(value).toFixed(2);
      } else {
        realVal = '--';
      }
      return realVal;
    },
  },
  methods: {
    //数字格式化
    fixData(row, column, cellValue, index) {
      if (cellValue != null && !isNaN(cellValue)) {
        if (cellValue < 0) {
          return '0.00';
        } else {
          return cellValue.toFixed(2);
        }
      } else {
        return '—';
      }
    },
    //卡券类型格式化
    couponType(row, column, cellValue, index) {
      if (row.couponId != null && row.couponId != '') {
        return '通用券';
      } else {
        return '—';
      }
    },
    //卡券属性格式化
    couponDetail(row, column, cellValue, index) {
      if (row.couponId != null && row.couponId != '') {
        return '满' + row.couponLimitMoney + '减' + row.couponMoney;
      } else {
        return '—';
      }
    },
    //查看订单详情
    showOrderDetail(v) {
      console.log('~🚀🚀🚀🚀~🚀🚀🚀🚀~🚀🚀🚀🚀~ ~ v:', v);
      this.orderItem.uuid = v.uuid;
      this.orderItem.orderNo = v.orderNo;
      this.orderItem.orgSeq = v.orgSeq;
      this.orderItem.orderStatus = v.orderStatus;
      this.orderItem.returnStatus = v.returnStatus;
      this.orderItem.orderStatusName = v.orderStatusName;
      this.orderItem.customizeStatus = v.customizeStatus;
      this.orderItem.orderTime = v.orderTime;
      this.orderItem.payTime = v.payTime;
      this.orderItem.deliveryMethodName = v.deliveryMethodName;
      this.orderItem.deliveryTime = v.deliveryTime;
      this.orderItem.authCode = v.authCode;
      this.orderItem.storeName = v.storeName;
      this.orderItem.shopOwnerName = v.shopOwnerName;
      this.orderItem.shopOwnerPhone = v.shopOwnerPhone;
      this.orderItem.warzoneName = v.warzoneName;
      this.orderItem.baseName = v.baseName;
      this.orderItem.gradelevelName = v.gradelevelName;
      this.orderItem.memberName = v.memberName;
      this.orderItem.memberPhone = v.memberPhone;
      this.orderItem.storeAddress = v.storeAddress;
      this.orderItem.postPerson = v.postPerson;
      this.orderItem.postPersonTel = v.postPersonTel;
      this.orderItem.postAddress = v.postAddress;
      this.orderItem.haveBuyLimitName = v.haveBuyLimitName;
      this.orderItem.haveGiftOrder = v.haveGiftOrder;
      this.orderItem.haveGiftOrderName = v.haveGiftOrderName;
      this.orderItem.orderSourceName = v.orderSourceName;
      this.orderItem.isFeastOrder = v.isFeastOrder;
      this.orderItem.completeDate = v.completeDate;
      this.orderItem.refundDate = v.refundDate;
      this.queryTradeOrderPayInfo(v.uuid);
      this.queryTradeOrderItemList(v.uuid);
      this.queryTradeOrderGiftList(v.uuid);
      this.queryTradeOrderDeliverList(v.uuid);
      this.queryTradeOrderFeastList(v.uuid);
    },
    //订单支付信息
    queryTradeOrderPayInfo(v) {
      let data = { orderId: v };
      this.payData = [];
      queryTradeOrderPayInfo(data).then((res) => {
        this.loading2 = false;
        this.payData.push(res.result);
      });
    },
    //订单商品信息
    queryTradeOrderItemList(v) {
      let data = { orderId: v };
      queryTradeOrderItemList(data).then((res) => {
        this.loading3 = false;
        this.itemData = res.records;
        if (this.orderItem.returnStatus != 0) {
          //退款物品信息
          this.loading4 = false;
          this.returnData = res.records;
        }
      });
    },
    //订单赠品信息
    queryTradeOrderGiftList(v) {
      if (this.orderItem.haveGiftOrder == 1) {
        let data = { orderId: v };
        queryTradeOrderGiftList(data).then((res) => {
          this.loading6 = false;
          this.giftData = res.records;
        });
      }
    },
    //订单赠品信息
    queryTradeOrderFeastList(v) {
      if (this.orderItem.isFeastOrder == '是') {
        let data = { orderId: v };
        queryTradeOrderFeastList(data).then((res) => {
          this.loading7 = false;
          this.feastData = res.records;
          /*
          let feastInfo = null;
          if(this.feastData != null && this.feastData.length > 0){
            this.feastData.forEach((item,i) => {
              if(i == 0){
                feastInfo = item.feastDate + " " + item.feastAddressDetail;
              }else{
                feastInfo = " , " + item.feastDate + " " + item.feastAddressDetail;
              }
            });
          }
          this.orderItem.feastInfo = feastInfo == null ? "无" : feastInfo;
          */
        });
      }
    },
    //订单物流信息
    queryTradeOrderDeliverList(v) {
      let data = { orderId: v };
      queryTradeOrderDeliverList(data).then((res) => {
        this.loading5 = false;
        this.deliverData = res.records;
      });
    },
    //展开卡券列表
    showCouponDetail(row) {
      let $table = this.$refs.table3;
      this.itemData.map((item) => {
        if (row.nu != item.nu) {
          $table.toggleRowExpansion(item, false);
          item.expansion = false;
        } else {
          item.expansion = !item.expansion;
        }
      });
      $table.toggleRowExpansion(row);
    },
    //展开物流详细
    showDeliverDetail(row) {
      let $table = this.$refs.table5;
      this.deliverData.map((item) => {
        if (row.goodsId != item.goodsId) {
          $table.toggleRowExpansion(item, false);
          item.expansion = false;
        } else {
          item.expansion = !item.expansion;
        }
      });
      $table.toggleRowExpansion(row);
    },
    //返回
    goback() {
      var pageFrom = sessionStorage.getItem('pageFrom');
      if (pageFrom == 'normalOrderSearch') {
        sessionStorage.setItem('pageFrom', 'normalOrderDetail');
        this.$router.push({
          name: 'normalOrderSearch',
          params: {},
        });
      }
      if (pageFrom == 'returnOrderSearch') {
        sessionStorage.setItem('pageFrom', 'returnOrderDetail');
        this.$router.push({
          name: 'returnOrderSearch',
          params: {},
        });
      }
      if (pageFrom == 'preSaleOrderSearch') {
        sessionStorage.setItem('pageFrom', 'normalOrderDetail');
        this.$router.push({
          name: 'preSaleOrderSearch',
          params: {},
        });
      }
    },

    // 取货码
    queryTdcode(orderId) {
      queryTdcode({
        orderId
      }).then(res => {
        if(res.code) {
          this.tdcode = res.result
        } else {
          this.$message.error(res.message)
        }
      })
    }
  },
  //其他
  computed: {},
};
</script>
<style>
#orderDetailDiv /deep/ .el-form--inline .el-form-item__content {
  width: 180px;
}
#orderDetailDiv /deep/ .el-range-editor.el-input__inner {
  width: 250px;
}
#orderDetailDiv /deep/ .el-dialog__body {
  padding-top: 0;
}
#orderDetailDiv /deep/ .table3 td.el-table__expand-column div.cell {
  display: none;
}
#orderDetailDiv /deep/ .table5 td.el-table__expand-column div.cell {
  display: none;
}
#couponDetail /deep/ table th,
#couponDetail /deep/ table td {
  border: 1px solid #ebeef5;
}
#couponDetail /deep/ table th {
  background: #eef1f6;
  color: #606266;
}
</style>
<style lang="scss" scoped>
.pick-up-code {
  padding: 10px;
  background-color: #fff;
  border-radius: 4px;
  border: 1px solid #dcdfe6;
  font-size: 14px;
  color: #606266;
}
</style>